<?php
class Admin_Block_Journal extends Epic_View_Block 
{	
	public function getAllJournal (){
		if (Epic::getSession()->get('admin')==false)
			header("Location: ".Epic::getUrl('admin/acc/login'));
			
		return Epic::getModel('admin/Journal')->getCollection()
				//->join ('pager as p','(m.id_journal=p.id_journal)',array('numpager'=>'COUNT(p.id_pager)'))
				//-> groupby (array (0=>'p.id_journal'))
				-> load();
	}	
	public function getJournal ($id) {
		if (Epic::getSession()->get('admin')==false)
			header("Location: ".Epic::getUrl('admin/acc/login'));
		return Epic::getModel('admin/Journal')
			->load($id);
	}
	public function getAllPagerOfJournal ($id_journal) {
		if (Epic::getSession()->get('admin')==false)
			header("Location: ".Epic::getUrl('admin/acc/login'));
		return Epic::getModel('admin/Pager')->getCollection()
			->where('id_journal', array('eq' => $id_journal))
			->load();					
	}
	public function getTopics () {
		return Epic::getModel('admin/Topic')->getCollection()
			->load();
	}
	public function getPager ($id) {
		return Epic::getModel('admin/Pager')
			->load($id);
	}
}